<template>
  <div class="toast" v-show="isShow">
    <div>{{ message }}</div>
  </div>
</template>

<script>
export default {
  // props: {
  //   message: {
  //     tpye: String,
  //     default: "",
  //   },
  //   show: {
  //     tpye: Boolean,
  //     default: false,
  //   },
  // },
  data() {
    return {
      message: "",
      isShow: false,
    };
  },
  methods: {
    show(message = "默认信息", duration = 2000) {
      // duration = duration || 2000
      this.message = message;
      this.isShow = true;

      setTimeout(() => {
        this.isShow = false;
        this.message = "";
      }, duration);
    },
  },
};
</script>

<style>
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 999;
  padding: 8px 10px;
  border-radius: 20px;
  transform: translate(-50%, -50%);
  color: azure;
  background-color: rgba(0, 0, 0, 0.7);
}
</style>